# coding: utf-8
# @Author: 莫小鱼
import yaml

from AutoWebTest.utils.log_util import logs


def read_yaml(file_path):
    """
    读取yaml文件的数据
    :param file_path: 文件路径
    :return: 返回列表类型，列表内时元组类型，如：[（'admin','123456'），（'',''），（'',''）]
    """
    try:
        data_list_tuple = []
        with open(file_path, 'r', encoding='utf-8') as file:
            data = yaml.load(file, Loader=yaml.FullLoader)  # Loader参数可以防止警告信息
            for data_str in data:
                if data_str is not None:
                    data_tuple = tuple(data_str.split(','))  # 返回最后一个元组
                    data_list_tuple.append(data_tuple)  # 将返回的元组添加到data_list_tuple中

        return data_list_tuple
    except Exception as e:
        logs.error(f"读取yaml文件异常,原因：{e}")


# res = read_yaml('../../data/login.yaml')
# print(res)
